package huzh.tag;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 *<p>title:IteratorTag</p>
 *<p>description:</p>
 * @since 2014-6-15
 * @author huzh
 * @version 1.0
 */
public class IteratorTag extends SimpleTagSupport{

    private String collection;
    
    private String item;
    
    public String getCollection() {
        return collection;
    }
    public void setCollection(String collection) {
        this.collection = collection;
    }
    public String getItem() {
        return item;
    }
    public void setItem(String item) {
        this.item = item;
    }
    
    @SuppressWarnings("unchecked")
    @Override
    public void doTag() throws JspException, IOException {
        Collection itemList = (Collection)getJspContext().getAttribute(collection);
        for(Object s: itemList){
            getJspContext().setAttribute(item, s);
            getJspBody().invoke(null);
        }
    }
    

}
